package com.jmu.posms.dto;

import com.jmu.posms.pojo.Permission;
import com.jmu.posms.pojo.Role;
import lombok.Data;

import java.util.*;

/**
 * 用户权限信息
 */
@Data
public class PermissionDto {
    /**
     * 用户的所有角色集合
     */
    private List<Role> roles;

    /**
     * 用户的所有权限集合
     */
    private Set<Permission> permissions;

    /**
     * 用户的权限所能访问的路径集合
     */
    private Map<String,String> urls;

    public void addRole(Role role){
        if(this.roles == null){
            this.roles = new ArrayList<>();
        }
        this.roles.add(role);
    }

    public void addPermission(Permission permission){
        if(this.permissions == null){
            this.permissions = new HashSet<>();
        }
        this.permissions.add(permission);
    }

    public void addUrl(String url,String permission){
        if(this.urls == null){
            this.urls = new HashMap<>();
        }
        this.urls.put(url,permission);
    }

}
